package com.hd.appcommon.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hd.appcommon.entity.RolePrivilege;
import com.hd.appcommon.mapper.RolePrivilegeMapper;
import com.hd.appcommon.service.IRolePrivilegeService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 角色关联权限 服务实现类
 * </p>
 *
 * @author administrator
 * @since 2020-11-30
 */
@Service
public class RolePrivilegeServiceImpl extends ServiceImpl<RolePrivilegeMapper, RolePrivilege> implements IRolePrivilegeService {

    @Override
    public List<RolePrivilege> listByPrivilegeId(String privilegeId) {
        LambdaQueryWrapper<RolePrivilege> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(RolePrivilege::getPrivilegeId, privilegeId);
        return this.list(wrapper);
    }

    @Override
    public List<RolePrivilege> listByRoleId(String roleId) {
        LambdaQueryWrapper<RolePrivilege> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(RolePrivilege::getRoleId, roleId);
        return this.list(wrapper);
    }

    @Override
    public boolean removeByPrivilegeId(String privilegeId) {
        LambdaQueryWrapper<RolePrivilege> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(RolePrivilege::getPrivilegeId, privilegeId);
        return this.remove(wrapper);
    }
}
